/**
 *博尔信基础开发平台
 *<br> 版权声明：厦门博尔信软件有限公司版权所有,违者必究
 *<br> Copyright:  Copyright (c) 2012
 *<br> Company:pearlsoft
 *<br> @author 蒋勇华
 *<br> 2012-5-16
 *<br> @version 1.0
 *————————————————————————————————————
 *修改记录
 *    修改者：
 *    修改时间：
 *    修改原因：
 *——————————————————————————————————————
 */
package com.pearlsoft.webapp.rms.restask;

import com.pearlsoft.webapp.core.annotation.DataSetHandlerComponent;
import com.pearlsoft.webapp.core.dataset.DataSet;
import com.pearlsoft.webapp.core.dataset.Record;
import com.pearlsoft.webapp.core.dataset.Result;
import com.pearlsoft.webapp.core.web.basehandler.AbsDataSetHandler;
import com.pearlsoft.webapp.rms.resrun.service.ResRunService;
import com.pearlsoft.webapp.rms.restask.service.ResTaskService;

/**
 *描述： 
 *
 * 
 */
@DataSetHandlerComponent(name = "ResTaskDataSetHandler")
public class ResTaskDataSetHandler extends AbsDataSetHandler{
	/**
	 * 执行
	 * @param ds
	 * @param result
	 * @throws Exception
	 */
	public void run(DataSet ds, Result result) throws Exception {
		Record record = ds.getCurrentRecord();
		ResTaskService resTaskService = this.getBean("resTaskService", ResTaskService.class);
		Record ret=resTaskService.run(record);
		result.getRecords().add(ret);
	}

	public void stop(DataSet ds, Result result) throws Exception {
		Record record = ds.getCurrentRecord();
		ResTaskService resTaskService = this.getBean("resTaskService", ResTaskService.class);
		resTaskService.stop(record);
	}
	/***
	 * 修改主机硬件配置参数
	 * @param ds
	 * @param result
	 * @throws Exception
	 */
	public void updateHostParam(DataSet ds, Result result) throws Exception {
		Record record = ds.getCurrentRecord();
		String vdcName = (String) record.getValue("vdcName");
		String vappName = (String) record.getValue("vappName");
		String vmName = (String) record.getValue("vmName");
		String cpu = (String) record.getValue("cpu");
		String memory = (String) record.getValue("memory");
		String appendDiskHard = (String) record.getValue("appendDiskHard");
		ResTaskService resTaskService = this.getBean("resTaskService", ResTaskService.class);
		resTaskService.updateHostParam(vdcName, vappName, vmName, cpu, memory, appendDiskHard);
	}
	
	
	@Override
	public void handler(DataSet ds, Result result) throws Exception {
		
	}


	@Override
	public void save(DataSet ds, Result result) throws Exception {
		
	}


	@Override
	public void delete(DataSet ds, Result result) throws Exception {
		
	}


	@Override
	public void deleteAll(DataSet ds, Result result) throws Exception {
		
	}

}
